<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>湖北省第十七届运动会成绩信息发布</title>
<meta name="keywords" content="湖北省运会成绩管理系统">
<meta name="description" content="湖北省运会成绩管理系统">

    <link rel="icon" href="${contextPath}static/favicon.png" type="image/x-icon" />
    <link rel="shortcut icon" href="${contextPath}static/favicon.png" />
<link href="${contextPath}static/css/bootstrap.min.css" rel="stylesheet">
<link href="${contextPath}static/css/font-awesome.min.css" rel="stylesheet">
<link href="${contextPath}static/css/sportPublic.css" rel="stylesheet">
<link href="${contextPath}static/css/tab.css" rel="stylesheet">

<script src="${contextPath}static/js/jquery-1.12.4.min.js?v=4"></script>
<script src="${contextPath}static/js/bootstrap.min.js?v=4"></script>
<script src="${contextPath}static/localijs/hhBase64.js?v=4"></script>
<script src="${contextPath}static/localijs/App.js?v=9"></script>
<script src="${contextPath}static/js/jquery.tabs.js"></script>

</head>
<body>
	<div class="big-bg"></div>
	<!-- 左边纵向导航 开始 -->
	<div class="nav-vertical">
		<div class="sport-logo">
            <img src="${contextPath}static/images/real_logo.png">
			<span
				class="sport-logo-txt">2026 · 孝感</span>
		</div>
		<div class="sport-menu">
			<ul class="sport-menu-list">
				<li <c:if test="${pid eq '12'}">class="active" </c:if>><a href="${contextPath}"> <i class="fa fa-futbol-o"></i>
						<span class="menu-li-txt">青少年体育类</span>
				</a></li>
				<li <c:if test="${pid eq '13'}">class="active"</c:if>><a href="${contextPath}qzty"> <i class="fa fa-universal-access"></i> <span
						class="menu-li-txt">群众体育类</span>
				</a></li>
				<li <c:if test="${pid eq '18'}">class="active"</c:if>><a href="${contextPath}shjlb"> <i class="fa fa-universal-access"></i> <span
						class="menu-li-txt">社会俱乐部类</span>
				</a></li>
                <li <c:if test="${pid==null && pid==''}">class="active"</c:if>>
                    <a href="${contextPath}zdxs">
                        <i class="fa fa-universal-access"></i>
                        <span class="menu-li-txt">大学生类</span>
                    </a>
                </li>
			</ul>
<%-- 			<div class="code">
				<img src="${contextPath}static/images/code.jpg" alt=""> <span>关注湖北省<br>运动会公众号
				</span>
			</div> --%>
		</div>
	</div>
	<!-- 左边纵向导航 结束 -->
 <div class="sport-content col-sm-12">
      <div class="sport-content-center">
        <div class="sport-title">湖北省第十七届运动会竞赛成绩信息发布</div>
        <div class="primary-content">
          <div class="primary-content-title">
            <h2><c:if test="${pid eq '12'}">青少年体育类</c:if><c:if test="${pid eq '13'}">群众体育类</c:if><c:if test="${pid eq '18'}">社会俱乐部类</c:if></h2>
            <div class="sport-tab">
              <ul class="nav nav-tabs">
                <li><a >总日程</a></li>
                <li><a >决赛成绩</a></li>
                <li><a >单项赛程</a></li>
                <li><a >纪录</a></li>
                 <li class="active"><a >奖牌榜</a></li>
              </ul>
            </div>
          </div>
          <div class="wrapper-content">
            <div class="sport-cell">

              <div class="every-bd box tabs" >
              	<c:if test="${pid==13}">
              		<ul class="tab_menu">
						<li  class="current"  value="1" >地市州榜</li>
						<li  value="5" >机关榜</li>
						<li  value="4" >企业榜</li>
					</ul>
              	</c:if>

				<div class="tab_box">
					<table class="table table-striped table-sport-item">
                      <thead>
                        <tr>
                        	<th style="text-align: center;">排名</th>
                            <th style="text-align: left;">单位</th>
                            <th style="text-align: left;">金牌🏅</th>
                            <th style="text-align: left;">银牌🥈</th>
                            <th style="text-align: left;">铜牌🥉</th>
                            <th style="text-align: left;">积分</th>
                        </tr>
                      </thead>
                      <tbody id="list">
                      <c:if test="${pid!=12 and pid!=13}">

                           <c:forEach var="s" items="${map}" varStatus="status">
                            <tr>
                                <td style="text-align: left;">${status.index+1}</td>
                                <td style="text-align: left;"><a onclick="App.ShowReportDetail('${s.unitName }',${s.uid},0)">${s.unitName }</a> </td>
                                <td style="text-align: left;"><a onclick="App.ShowReportDetail('${s.unitName }',${s.uid},1)">${fn:split(s.goldNum,'.')[0] }</a></td>
                                <td style="text-align: left;"><a onclick="App.ShowReportDetail('${s.unitName }',${s.uid},2)">${fn:split(s.silverNum,'.')[0] }</a></td>
                                <td style="text-align: left;"><a onclick="App.ShowReportDetail('${s.unitName }',${s.uid},3)">${fn:split(s.bronzeNum,'.')[0] }</a></td>
                                <td style="text-align: left;">${s.allPoints }</td>
                            </tr>
                            </c:forEach>
                      </c:if>
                      </tbody>
                    </table>
				</div>
              </div>
            </div>
          </div>
        </div>
        <div class="sport-footer">
          <p>建议使用IE9及以上版本浏览器 <br>版权所有 湖北省体育局</p>
        </div>
      </div>
    </div>

    <!-- 返回顶部 开始 -->
    <div class="gototop" style="display: none;">
      <a href="javascript:;" title="返回顶部"><i class="fa fa-angle-up"></i></a>
    </div>
    <!-- 返回顶部 结束 -->

    <script>
 	App.OnclickHandle('${contextPath}','${pid}');
    // 月份切换
    $(".every-date-tab ul li").click(function(){
        $(this).addClass('active').siblings().removeClass('active');
        var index = $(".every-date-tab ul li").index(this);
        $(".every-days-cell").eq(index).show().siblings().hide();
    })

    //返回顶部
    $(window).scroll(function(){
        if ($(window).scrollTop()>=200) {
            $(".gototop").fadeIn(300);
        }else{
            $(".gototop").fadeOut(300);
        }
    })
    $(".gototop").click(function(){
        $('html,body').animate({'scrollTop':'0px'},300);
    })

    //表格展开收起
    $(".small-toggle").click(function(){
      if($(this).find(".fa").hasClass('fa-arrow-circle-up')){
        $(this).parents(".someone-item").find(".table-sport-item").slideUp(300);
        $(this).find(".fa").addClass('fa-arrow-circle-down').removeClass('fa-arrow-circle-up');
        $(this).find(".toggle-txt").text("展开");
      }else{
        $(this).parents(".someone-item").find(".table-sport-item").slideDown(300);
        $(this).find(".fa").addClass('fa-arrow-circle-up').removeClass('fa-arrow-circle-down');
        $(this).find(".toggle-txt").text("收起");
      }
    })

    $(()=> {
        <c:if test="${pid==12}">
            function rankingFor12() {//为青少年类查询排名
                $('#list').empty();
                $.ajax({
                    url:  "${contextPath}reportInfo/query12WithAccountType",
                    dataType: "json",
                    success: function (data) {
                        let resultArr = [];
                        let tempArr = data.filter(one => one.classA === '青少年体育类')
                        let tempArr2 = tempArr.filter(e => e.classB === '体校组')
                        let tempArr3 = tempArr.filter(e => e.classB === '中学生组')
                        rankingAdapter(resultArr, tempArr2, tempArr3, tempArr)
                        resultArr.sort((a, b) => {
                            if (a.rankingFirst == b.rankingFirst) {
                                if (a.rankingSecond == b.rankingSecond) {
                                    return b.rankingThree - a.rankingThree
                                }
                                return b.rankingSecond - a.rankingSecond
                            }
                            return b.rankingFirst - a.rankingFirst
                        })
                        data = data.filter(one => one.classA !== '青少年体育类')
                        resultArr.forEach(e => data.push(e))
                        handleAccountType1AndGold(data)

                    },
                    beforeSend : function() {
                        $("#Loading").show();
                    },
                    complete: function () {
                        $("#Loading").hide();
                    }

                })
            }
            rankingFor12();

            function rankingAdapter(resultArr, arr1, arr2, all) {

                //体校组
                arr1.forEach((e, i, arr) => {
                    let sameOne = all.filter(obj => (obj.classB != e.classB) && (obj.unitName == e.unitName))//中学生
                    let oneElement = {
                        first: 0,
                        second: 0,
                        three: 0,
                        integral: 0,
                        unitName: e.unitName
                    };
                    sameOne.forEach(ele => {
                        oneElement.first += parseInt(ele.first)
                        oneElement.second += parseInt(ele.second)
                        oneElement.three += parseInt(ele.three)
                        oneElement.integral += parseInt(ele.integral)
                    })
                    let obj = {};
                    if (sameOne.length >= 1) {
                        obj.uid=e.uid
                        obj.accountType = 1
                        obj.classA = '青少年体育类'
                        obj.unitName = e.unitName
                        obj.first = e.first + "+" + oneElement.first
                        obj.integral = e.integral + "+" + oneElement.integral
                        obj.second = e.second + "+" + oneElement.second
                        obj.three = e.three + "+" + oneElement.three
                        obj.rankingFirst = parseInt(e.first) + parseInt(oneElement.first)
                        obj.rankingSecond = parseInt(e.second) + parseInt(oneElement.second)
                        obj.rankingThree = parseInt(e.three) + parseInt(oneElement.three)
                        obj.rankingIntegral = parseFloat(e.integral) + parseFloat(oneElement.integral)

                        arr2.forEach((e, i, arr) => {
                            if (e.unitName == oneElement.unitName) {
                                e.existed = true;
                            }
                        })
                    } else {
                        obj.uid=e.uid
                        obj.accountType = 1
                        obj.classA = '青少年体育类'
                        obj.unitName = e.unitName
                        obj.first = e.first + "+0"
                        obj.integral = e.integral + "+0"
                        obj.second = e.second + "+0"
                        obj.three = e.three + "+0"
                        obj.rankingFirst = e.first
                        obj.rankingSecond = e.second
                        obj.rankingThree = e.three
                        obj.rankingIntegral = e.integral
                    }

                    resultArr.push(obj)
                })
                arr2 = arr2.filter(e => !e.existed)
                arr2.forEach((e, i, arr) => {
                    let sameOne = all.filter(obj => (obj.classB != e.classB) && (obj.unitName == e.unitName))
                    let oneElement1 = {
                        first: 0,
                        second: 0,
                        three: 0,
                        integral: 0
                    };
                    sameOne.forEach(ele => {
                        oneElement1.first += parseInt(ele.first)
                        oneElement1.second += parseInt(ele.second)
                        oneElement1.three += parseInt(ele.three)
                        oneElement1.integral += parseInt(ele.integral)
                    })
                    let obj = {};
                    if (sameOne.length >= 1) {
                        obj.uid=e.uid
                        obj.accountType = 1
                        obj.classA = '青少年体育类'
                        obj.unitName = e.unitName
                        obj.first = oneElement1.first + "+" + e.first
                        obj.integral = oneElement1.integral + "+" + e.integral
                        obj.second = oneElement1.second + "+" + e.second
                        obj.three = oneElement1.three + "+" + e.three
                        obj.rankingFirst = parseInt(e.first) + parseInt(oneElement1.first)
                        obj.rankingSecond = parseInt(e.second) + parseInt(oneElement1.second)
                        obj.rankingThree = parseInt(e.three) + parseInt(oneElement1.three)
                        obj.rankingIntegral = parseFloat(e.integral) + parseFloat(oneElement1.integral)
                    } else {
                        obj.uid=e.uid
                        obj.accountType = 1
                        obj.classA = '青少年体育类'
                        obj.unitName = e.unitName
                        obj.first = "0+" + e.first
                        obj.integral = "0+" + e.integral
                        obj.second = "0+" + e.second
                        obj.three = "0+" + e.three
                        obj.rankingFirst = e.first
                        obj.rankingSecond = e.second
                        obj.rankingThree = e.three
                        obj.rankingIntegral = e.integral
                    }
                    resultArr.push(obj)
                })
            }
            function handleAccountType1AndGold(data) {
                let totalMedalNum1 = [0, 0, 0, 0]
                let trArr = [];
                if (data.length > 0) {
                    let tdArr1 = [];
                    let index1 = 1
                    for (var i = 0; i < data.length; i++) {
                        var bean = data[i];
                        var classA = bean.classA;
                        let total = 0;
                        if (classA == '青少年体育类') {
                            total = parseInt(bean.rankingFirst) + parseInt(bean.rankingSecond) + parseInt(bean.rankingThree)
                            totalMedalNum1[0] += parseInt(bean.rankingFirst)
                            totalMedalNum1[1] += parseInt(bean.rankingSecond)
                            totalMedalNum1[2] += parseInt(bean.rankingThree)
                            totalMedalNum1[3] += parseInt(bean.integral)
                            tdArr1.push(
                                '<tr style="height: 30px;">'+
                                    '<td>' + index1 + '</td>' +
                                    '<td style="text-align: left;"><a onclick="App.ShowReportDetail(\''+bean.unitName+'\','+bean.uid+',0)">' + bean.unitName + '</a></td>' +
                                    '<td style="text-align: left;"><a onclick="App.ShowReportDetail(\''+bean.unitName+'\','+bean.uid+',1)">' + bean.first + '</a></td>' +
                                    '<td style="text-align: left;"><a onclick="App.ShowReportDetail(\''+bean.unitName+'\','+bean.uid+',2)">' + bean.second + '</a></td>' +
                                    '<td style="text-align: left;"><a onclick="App.ShowReportDetail(\''+bean.unitName+'\','+bean.uid+',3)">'+ bean.three + '</a></td>' +
                                    '<td style="text-align: left;">' + bean.integral + '</td>'+
                                '</tr>'
                            )
                            index1 = index1 + 1
                        }
                    }
                    for (var i = 0; i < tdArr1.length; i++) {
                        let td1 = tdArr1[i];
                        trArr.push( td1)
                    }
                    let totalTd =
                        '<td>#</td>' +
                        '<td style="color:red;font-weight:bold;text-align: left;">总计</td>' +
                        '<td style="text-align: left;">' + totalMedalNum1[0] + '</td>' +
                        '<td style="text-align: left;">' + totalMedalNum1[1] + '</td>' +
                        '<td style="text-align: left;">' + totalMedalNum1[2] + '</td>' +
                        '<td style="text-align: left;">' + totalMedalNum1[3] + '</td>'
                    trArr.push('<tr style="height: 30px;">' + totalTd + '</tr>')
                    $('#list').append(trArr.join(''))
                }
            }
        </c:if>
        <c:if test="${pid==13}">
            $(".sport-cell .box li").click((e)=>{
                $(e.target).siblings().removeClass("current")
                $(e.target).addClass("current")
                rankingFor13()
            })

            function rankingFor13(){
                $('#list').empty();
                var html = '';
                var account = $(".sport-cell .box li[class='current']").attr('value')
                console.log(account)
                $.ajax({
                    url: "${contextPath}reportInfo/queryTeenagersThreeList/13?",
                    dataType: "json",
                    data:{account:account},
                    success: function(data){
                        for(var i =0;i<data.length;i++){
                            var rank = i+1;
                            var map = data[i];
                            html = "<tr>" +
                                "<td>"+rank+"</td>" +
                                "<td style='text-align: left;'><a onclick='App.ShowReportDetail(\""+map.单位+"\","+map.uid+",0)'>"+isStrNUll(map.单位)+"</a></td>" +
                                "<td style='text-align: left;'><a onclick='App.ShowReportDetail(\""+map.单位+"\","+map.uid+",1)'>"+isStrNUll(map.金牌)+"</a></td>" +
                                "<td style='text-align: left;'><a onclick='App.ShowReportDetail(\""+map.单位+"\","+map.uid+",2)'>"+isStrNUll(map.银牌)+"</a></td>" +
                                "<td style='text-align: left;'><a onclick='App.ShowReportDetail(\""+map.单位+"\","+map.uid+",3)'>"+isStrNUll(map.铜牌)+"</a></td>" +
                                "<td style='text-align: left;'>"+isStrNUll(map.总分)+"</td>" +
                                "</tr>";
                            $('#list').append(html)
                        }
                    },
                    beforeSend : function() {
                        $("#Loading").show();
                    },
                    complete: function () {
                        $("#Loading").hide();
                    }
                })

            }
            rankingFor13()
            //判断后台返回null时返回0
            function isStrNUll(obj) {
                if (obj == null) {
                    return "0";
                } else {
                    return obj;
                }
            }

        </c:if>
    })
    </script>
  </body>
</html>
